﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DemodStatusAnalysis
{
    internal static class StringHelper
    {
        public static DateTime toDatetime(this string str)
        {
            //DateTime dts;
            //var res = DateTime.TryParse(str, "yyyy-MM-dd HH:mm:ss.fff",DateTimeStyles.None, out dts);
            try
            {
                DateTime dt = DateTime.ParseExact(str, "yyyy-MM-dd HH:mm:ss.fff", System.Globalization.CultureInfo.CurrentCulture);
                return dt;
            }
            catch
            {
                return DateTime.Now;
            }
        }

        public static double toDouble(this string str)
        {
            double result;
            var br = double.TryParse(str, out result);
            return result;
        }
    }
}